<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>内容管理</title>
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/res/third/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
 <link href="/res/third/powerFloat/css/powerFloat.css" rel="stylesheet" type="text/css" />
 <script src="/res/third/powerFloat/js/mini/jquery-powerFloat-min.js" type="text/javascript"></script>
<style>


</style>
<script type="text/javascript">

var coins='${coins!}';

$(document).ready(function(){
	$("[name='wtmon'],[name='bili']").blur(function(){
		var wtmon=$("[name='wtmon']").val().trim();
		var bili=$("[name='bili']").val().trim();
		if(wtmon==""||bili==""){
			
		}else{
			var xudikou=parseInt(parseFloat(wtmon)*(parseFloat(bili)/100));
			$("[name='xudikou']").val(xudikou);
			var dikou=parseInt(coins)-xudikou;
			if(dikou>=0){
				$("[name='yidikou']").val(xudikou);
			}else{
				$("[name='yidikou']").val(coins);
			}
		}
	});
	 
});

function subForm(){
	var wtmon=$("[name='wtmon']").val().trim();
	var bili=$("[name='bili']").val().trim();
	if(wtmon==""||bili==""){
		alert("委托采购金额和比例不能为空");
		return false;
	}
	
	var xudikou = parseInt($("[name='xudikou']").val());
	var yidikou = parseInt($("[name='yidikou']").val());
	if(xudikou != yidikou) {
        $("#xudikou").val(yidikou);
	}
    if(yidikou == 0) {
		alert("抵扣安装币为0");
		return false;
    }

	var coinRecord={};
	coinRecord.companyId=$("#companyId").val();
	coinRecord.descr="委托采购抵扣安装币:"+$("#xudikou").val();
	coinRecord.coinAmount=$("#xudikou").val();
	
	art.dialog.post({
		  
		type : "post",
		dataType : "json",
		url : "/coin/coin_dikou.do",
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(coinRecord),
		success : function(data) {
			 if(data.success){
				 alert(data.msg);
				 top.closeTempTab(true);
			 }else{
				 alert(data.msg);
			 }
		}
 
	},"数据正在提交.... ");
	
}
</script>
</head>
<body>
<!-- 新建 -->
	   <div class="panel panel-info">
	        <div class="panel-heading">
	          <h3 class="panel-title">安装币扣减</h3>
	        </div>
        <div class="panel-body" style="overflow: hidden;border-bottom: none;">
			<form class="form-horizontal" role="form"   id="mainForm">
			  <input type="hidden" id="companyId" name="companyId" value="${company.id!}">
			  <div class="form-group" style="margin-top:15px;">
			    <label for="title" class="col-sm-2 control-label"><span style="color:red;">*</span>供应商名称</label>
			    <div class="col-sm-5">
			      <input type="text" class="form-control" id="companyName" placeholder="采购商名称" name="companyName" required="required" readonly="readonly" value="${company.companyName!}">
			    </div>
			  </div>
			  <div class="form-group">
			    <label for="title" class="col-sm-2 control-label"><span style="color:red;">*</span>安装币余额</label>
			    <div class="col-sm-5">
			      <input type="text" class="form-control" id="coins" placeholder="请输入规则标题" name="coins" required="required" readonly="readonly" value="${coins!}">
			    </div>
			  </div>
			  <div class="form-group" style="margin-top:15px;">
			    <label for="title" class="col-sm-2 control-label"><span style="color:red;">*</span>委托采购金额(元)</label>
			    <div class="col-sm-5">
                    <div class="input-group" style="width: 250px;">
                        <div class="input-group-addon">￥</div>
						<input type="number" class="form-control" id="wtmon" placeholder="委托采购金额" name="wtmon" required="required" >
                        <div class="input-group-addon">元</div>
                    </div>
			    </div>
			  </div>
			  <div class="form-group" style="margin-top:15px;">
			    <label for="title" class="col-sm-2 control-label"><span style="color:red;">*</span>抵扣比例(%)</label>
			    <div class="col-sm-5">
                    <div class="input-group" style="width: 200px;">
                        <input type="number" class="form-control" id="bili" placeholder="请填写比例%" name="bili" required="required">
                        <div class="input-group-addon">%</div>
                    </div>
			    </div>
			  </div>
			  <div class="form-group" style="margin-top:15px;">
			    <label for="title" class="col-sm-2 control-label">需抵扣安装币</label>
			    <div class="col-sm-5">
			      <input type="text" class="form-control" id="xudikou"  name="xudikou" required="required" readonly="readonly" style="width: 150px;">
			    </div>
			  </div>
			   <div class="form-group" style="margin-top:15px;">
			    <label for="title" class="col-sm-2 control-label">可抵扣安装币</label>
			    <div class="col-sm-5">
			      <input type="text" class="form-control" id="yidikou" name="yidikou" required="required" readonly="readonly" style="width: 150px;">
			    </div>
			  </div>
			  <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
			      <!--  
			      <button type="button" class="btn btn-info" onclick="validateForm();">提交</button>
			      -->
			      <button type="button" class="btn btn-info" onclick="subForm();">提交</button>
			    </div>
			  </div>
			</form>
        </div>
      </div>
</body>
</html>

